﻿<!--头部文件-->
<include file="Public/header"/>
<!--头部文件结束-->


<div class="wrapper">
    <!--左侧菜单栏-->
    <include file="Public/menu"/>
    <!--左侧菜单栏结束-->

    <div class="main-panel">
        <nav class="navbar navbar-default">
            <div class="container-fluid">
				<div class="navbar-minimize">
					<button id="minimizeSidebar" class="btn btn-warning btn-fill btn-round btn-icon">
						<i class="fa fa-ellipsis-v visible-on-sidebar-regular"></i>
						<i class="fa fa-navicon visible-on-sidebar-mini"></i>
					</button>
				</div>
                <div class="navbar-header">
                    <a class="navbar-brand" href="#">修改密码</a>
                </div>
            </div>
        </nav>



        <div class="content">
            <div class="container-fluid">

                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <form id="admin_form" class="form-horizontal" action="__APP__/Staffs/update/id/{$admin.id}" method="post">
                                <div class="content">
                                    <legend>修改密码<span style='font-size:15px;color:orange'>（密码修改后需重新登陆）</span></legend>
                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label"></label>
                                            <div class="col-sm-6"></div>
                                        </div>
                                    </fieldset>

                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">登陆账号</label>
                                            <div class="col-sm-6">
                                                <input class="form-control username" type="text" value="{$admin.username}" disabled="disabled"/>
                                            </div>
                                        </div>
                                    </fieldset>

                                    <br/>

                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label"><span style="color:red">*&nbsp;</span>旧密码</label>
                                            <div class="col-sm-6">
                                                <input class="form-control old_password" type="password" name="old_password" placeholder="请输入原登陆密码" onkeyup="value=value.replace(/[^\S]+/g,'')"/>
                                            </div>
                                        </div>
                                    </fieldset>

                                    <br/>

                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label"><span style="color:red">*&nbsp;</span>新密码</label>
                                            <div class="col-sm-6">
                                                <input class="form-control new_password" type="password" name="new_password" placeholder="请输入5到30位字符长度的新密码" onkeyup="value=value.replace(/[^\S]+/g,'')"/>
                                            </div>
                                        </div>
                                    </fieldset>

                                    <br/>

                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label"><span style="color:red">*&nbsp;</span>重复密码</label>
                                            <div class="col-sm-6">
                                                <input class="form-control new_password2" type="password" name="new_password2" placeholder="请再次输入密码" onkeyup="value=value.replace(/[^\S]+/g,'')"/>
                                            </div>
                                        </div>
                                    </fieldset>

                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label"></label>
                                            <div class="col-sm-3">
                                                <span id="admin_success" style="padding-left:4%;color:red"></span>
                                            </div>
                                        </div>
                                    </fieldset>
                                </div>
                                <div class="footer text-left">
                                    <button id="button_yes" type="button" class="btn btn-info btn-fill">提交</button>
                                    
                                 <br/>
                                    <br/>
                                </div>
                            </form>
                        </div>
                    </div>
                    </div>
            </div>
        </div>

        <!--底部文件-->
        <include file="Public/footer"/>
        <!--底部文件结束-->


    </div>
</div>

</body>

    <!--   Core JS Files and PerfectScrollbar library inside jquery.ui   -->
    <script src="__ROOT__/public/js/jquery.min.js" type="text/javascript"></script>
    <script src="__ROOT__/public/js/jquery-ui.min.js" type="text/javascript"></script>
	<script src="__ROOT__/public/js/bootstrap.min.js" type="text/javascript"></script>


	<!--  Forms Validations Plugin -->
	<script src="__ROOT__/public/js/jquery.validate.min.js"></script>
	<!--  Plugin for Date Time Picker and Full Calendar Plugin-->
	<script src="__ROOT__/public/js/moment.min.js"></script>
    <!--  Date Time Picker Plugin is included in this js file -->
    <script src="__ROOT__/public/js/bootstrap-datetimepicker.js"></script>
    <!--  Select Picker Plugin -->
    <script src="__ROOT__/public/js/bootstrap-selectpicker.js"></script>
	<!--  Checkbox, Radio, Switch and Tags Input Plugins -->
	<script src="__ROOT__/public/js/bootstrap-checkbox-radio-switch-tags.js"></script>
	<!--  Charts Plugin -->
	<script src="__ROOT__/public/js/chartist.min.js"></script>
    <!--  Notifications Plugin    -->
    <script src="__ROOT__/public/js/bootstrap-notify.js"></script>
    <!-- Sweet Alert 2 plugin -->
	<script src="__ROOT__/public/js/sweetalert2.js"></script>
    <!-- Vector Map plugin -->
	<script src="__ROOT__/public/js/jquery-jvectormap.js"></script>
    <!--  Google Maps Plugin    -->
    <script src="__ROOT__/public/js/aa743e8f448a4792bad10d201a7080f6.js"></script>
	<!-- Wizard Plugin   -->
    <script src="__ROOT__/public/js/jquery.bootstrap.wizard.min.js"></script>
	<!--  Bootstrap Table Plugin    -->
	<script src="__ROOT__/public/js/bootstrap-table.js"></script>
	<!--  Plugin for DataTables.net  -->
	<script src="__ROOT__/public/js/jquery.datatables.js"></script>
    <!--  Full Calendar Plugin    -->
    <script src="__ROOT__/public/js/fullcalendar.min.js"></script>
    <!-- Light Bootstrap Dashboard Core javascript and methods -->
	<script src="__ROOT__/public/js/light-bootstrap-dashboard.js"></script>
	<!--   Sharrre Library    -->
    <script src="__ROOT__/public/js/jquery.sharrre.js"></script>
	<!-- Light Bootstrap Dashboard DEMO methods, don't include it in your project! -->
	<script src="__ROOT__/public/js/demo.js"></script>
<script src="__ROOT__/public/js/new_js.js"></script>

<script>
    $('li.Oneself').addClass('active');
    $('a.Oneself-a').attr('aria-expanded','true');
    $('div.Oneself-div').addClass('in');
    $('li.Oneself-update_pwd').addClass('active');

    $('#button_yes').click(function(){
        $('#admin_success').text('');
        var old_password=$('.old_password').val();
        var new_password=$('.new_password').val();
        var new_password2=$('.new_password2').val();

        if(old_password.length==''){
            $('#admin_success').text('请输入原密码');
        }else if(new_password.length<5 || new_password.length>30){
            $('#admin_success').text('新密码长度必须在5到30位字符长度之间');
        }else if(new_password!=new_password2){
            $('#admin_success').text('两次密码输入不一致');
        }else if(old_password==new_password){
            $('#admin_success').text('新密码不能与原密码相同');
        }else{
            $.ajax({
                type:'post',
                url:"__APP__/Oneself/up_pwd",
                data:'old_password='+old_password+'&new_password='+new_password+'&id={$admin.id}',
                success:function(data){
                    if(data=='no-old_password'){
                        $('#admin_success').text('旧密码错误');
                    }else if(data=='ok'){
                        window.location.href='__APP__/Login/index.html';
                    }else{
                        $('#admin_success').text('修改失败，请检查新密码是否符合要求');
                    }
                }
            })
        }
    })
</script>
<script>
    $('.jurisdiction option[value={$admin.jurisdiction}]').prop('selected','selected');

    $('.pwd').click(function(){
        if($('.pwd').prop('checked')==true){
            $('.password').prop('disabled','').attr('name','password');
        }else{
            $('.password').val('').prop('disabled','disabled').removeAttr('name');
        }
    })
</script>
</html>
